//泛型函数
function getId<T>(id: T):T {
    return id
}
let id1 = getId<number>(4)
console.log(id1);
let id2 = getId<{ name: string, age: number }>({ name: 'lihua', age: 22 })
console.log(id2);

//泛型别名
type ApiRes<T> = {
    code: number,
    data: T,
    message:string
}
type User = {
    nickname: string,
    avatar: string,
    qq?:string
}
// 后台返回的用户信息数据
const res: ApiRes<User> = {
    code: 200,
    data: {
        nickname: 'wenhua',
        avatar: 'http://www.xx.png',
        qq:'14845'
    },
    message:'请求成功'
}
console.log(res);


export{}